package com.cnswhy.cloud.server.core.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cnswhy.cloud.common.core.base.mapper.SuperMapper;
import com.cnswhy.cloud.server.common.entity.enumeration.TransType;
import com.cnswhy.cloud.server.core.dto.CustomerWalletTransDtlPageDTO;
import com.cnswhy.cloud.server.core.entity.*;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * 
 * </p>
 *
 * @author cnswhy
 * @date 2020-10-14
 */
@Repository
public interface WalletTransDtlMapper extends SuperMapper<WalletTransDtl> {
    /**
     * "<script>"
     *             + "SELECT "
     *             + "a.id as 'id',a.create_date as 'createDate',a.content as 'content',"
     *             + "a.parent_id as 'parentId',a.first_comment_id as 'firstCommentId',"
     *             + "b.id as 'fromUser.id',b.realname as 'fromUser.realname',b.avatar as 'fromUser.avatar',"
     *             + "c.id as 'toUser.id',c.realname as 'toUser.realname',c.avatar as 'toUser.avatar' "
     *             + "FROM t_demand_comment a "
     *             + "LEFT JOIN t_user b ON b.id = a.from_uid "
     *             + "LEFT JOIN t_user c ON c.id = a.to_uid "
     *             + "WHERE a.demand_id = #{demandId} "
     *             + "ORDER BY a.create_date ASC "
     *             + "<if test='startNo!=null and pageSize != null '>"
     *             + "LIMIT #{startNo},#{pageSize}"
     *             + "</if>"
     *             + "</script>"
     * @param settDate
     * @param transType
     * @return
     */
    @Select("select ifnull(sum(t.ded_bal),0) from t_wallet_trans_dtl t where t.sett_date = #{settDate} and trans_type = #{transType}")
    Long getSumMoneyBySettDateAndTransType(@Param("settDate") String settDate, @Param("transType")TransType transType);
    //@Select("select w.customer_id,c.login_name,w.wallet_type,w.avlb_balance, d.id,d.trans_type,d.ded_bal,d.trans_order_id,d.begin_bal,d.end_bal from t_wallet_trans_dtl d left join t_customer_wallet w on d.customer_wallet_id = w.id left join t_customer c on w.customer_id  = c.id")
    IPage<CustomerWalletTransDtl> getCustomerWalletTransDtl(IPage page, @Param("data") CustomerWalletTransDtlPageDTO customerWalletTransDtlPageDTO);
    //List<CustomerWalletTransDtl> exportCustomerWalletTransDtl(@Param("data") CustomerWalletTransDtlPageDTO customerWalletTransDtlPageDTO);
    List<CustomerWalletTransExcelDtl> exportCustomerWalletTransDtl(@Param("data") CustomerWalletTransDtlPageDTO customerWalletTransDtlPageDTO);
    List<CustomerWalletTransExcelDtl> exportCustomerWalletTransDtl1(@Param("data") CustomerWalletTransDtlPageDTO customerWalletTransDtlPageDTO);
    IPage<IntegralLog> getIntegralLog(IPage page, @Param("customerId") Long customerId,@Param("type") Integer type);
    IPage<SpreadLog> getSpreadLog(IPage page, @Param("customerId") Long customerId, @Param("type") Integer type);
}
